package com.zd.otherapi.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysDictData;
import com.ruoyi.system.mapper.SysDictDataMapper;
import com.zd.escortaction.dto.EscortActionDto;
import com.zd.lwsq.domain.ApplicationInfo;
import com.zd.lwsq.service.ApplicationInfoService;
import com.zd.otherapi.service.ApiApplicationInfoService;
import org.apache.commons.io.FilenameUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 离乌申请数据Controller
 * 
 * @author fxiao
 * @date 2020-08-07
 */
@Controller
@RequestMapping("/api/lwsq/lwsq")
public class ApiApplicationInfoController extends BaseController
{
    private String prefix = "lwsq/lwsq";

    @Autowired
    private ApplicationInfoService applicationInfoService;

    @Autowired
    private SysDictDataMapper dictDataMapper;
    @Autowired
    private ApiApplicationInfoService apiApplicationInfoService;

    @GetMapping()
    public String lwsq()
    {
        return prefix + "/lwsqapi";
    }


    /**
     * 新增离乌申请数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存离乌申请数据
     */
    @Log(title = "离乌申请数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    @RepeatSubmit
    public AjaxResult  addSave(ApplicationInfo applicationInfo)
    {
        try {
            if(applicationInfo!=null&& applicationInfo.getId()!=null && !applicationInfo.getId().equals("")){
                applicationInfoService.updateApplicationInfo(applicationInfo);
                return   new AjaxResult(AjaxResult.Type.SUCCESS,"保存成功！",applicationInfo.getId());
            }
            applicationInfoService.insertApplicationInfo(applicationInfo);

            return   new AjaxResult(AjaxResult.Type.SUCCESS,"添加成功",applicationInfo.getId());
        }catch(Exception e){
            e.printStackTrace();
            if(e.getMessage().indexOf("Duplicate")>0){
                return new AjaxResult(AjaxResult.Type.ERROR,"添加失败，您已经添加！请查询修改");
            }
            return new AjaxResult(AjaxResult.Type.ERROR,"添加失败:"+e.getMessage());
        }

    }

    /**
     * 网信办-修改离乌申请数据
     */
    @PostMapping("/getByCardId")
    public String edit(String cardId, ModelMap mmap)
    {
        ApplicationInfo applicationInfo = applicationInfoService.selectApplicationInfoByCardId(cardId);
        mmap.put("applicationInfo", applicationInfo);
        if(applicationInfo==null){
            return prefix+"/noData";
        }
        String by9=applicationInfo.getBy9();
        if(by9!=null && by9.indexOf(",")>0) {
            String[] split = by9.split(",");
            List<String> pics = new ArrayList<>();
            for (int i = 0; i < split.length; i++) {
                int offset = split[i].indexOf("//");
                pics.add(split[i].substring(offset + 2));
            }
            mmap.put("pics",pics);
        }

        return prefix + "/h5edit";
    }
    /**
     * 科信需求-修改离乌申请数据
     */
    @PostMapping("/getByCId")
    public String sqedit(String cardId, ModelMap mmap)
    {
        ApplicationInfo applicationInfo = applicationInfoService.selectApplicationInfoByCardId(cardId);
        mmap.put("applicationInfo", applicationInfo);
        if(applicationInfo==null){
            return prefix+"/noData";
        }
//        String by9=applicationInfo.getBy9();
//        if(by9!=null && by9.indexOf(",")>0) {
//            String[] split = by9.split(",");
//            List<String> pics = new ArrayList<>();
//            for (int i = 0; i < split.length; i++) {
//                int offset = split[i].indexOf("//");
//                pics.add(split[i].substring(offset + 2));
//            }
//            mmap.put("pics",pics);
//        }

        return prefix + "/sqedit";
    }
    /**
     * 根据id查询个人信息
     */
    @GetMapping("/getById")
    public String getById(String aid, ModelMap mmap)
    {
        ApplicationInfo applicationInfo = applicationInfoService.selectApplicationInfoById(aid);
        mmap.put("applicationInfo", applicationInfo);
        if(applicationInfo==null){
            return prefix+"/noData";
        }
        return prefix + "/h5info";
    }

    /**
     * 修改保存离乌申请数据
     */
    @Log(title = "离乌申请数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ApplicationInfo applicationInfo)
    {
        return toAjax(applicationInfoService.updateApplicationInfo(applicationInfo));
    }

    /**
     * 根据身份证号查询个人信息
     */
    @GetMapping("/getInfoBycardId")
    @ResponseBody
    public AjaxResult getInfoBycardId(String id)
    {
        if(id!=null && !id.trim().equals("")){
            ApplicationInfo  applicationInfo=applicationInfoService.selectApplicationInfoByCardId(id);
            if(applicationInfo!=null)
            return   new AjaxResult(AjaxResult.Type.SUCCESS,"您已经登记",id);
        }
        return  new AjaxResult(AjaxResult.Type.SUCCESS,"您可以正常登记");
    }

    @GetMapping("/cityData")
    @ResponseBody
    public String cityData()
    {
        String data="[{\"s\":[{\"n\":\"长沙市\",\"s\":[{\"n\":\"芙蓉区\"},{\"n\":\"天心区\"},{\"n\":\"岳麓区\"},{\"n\":\"开福区\"},{\"n\":\"雨花区\"},{\"n\":\"望城区\"},{\"n\":\"长沙县\"},{\"n\":\"宁乡县\"},{\"n\":\"浏阳市\"}]},{\"n\":\"株洲市\",\"s\":[{\"n\":\"荷塘区\"},{\"n\":\"芦淞区\"},{\"n\":\"石峰区\"},{\"n\":\"天元区\"},{\"n\":\"株洲县\"},{\"n\":\"攸县\"},{\"n\":\"茶陵县\"},{\"n\":\"炎陵县\"},{\"n\":\"醴陵市\"}]},{\"n\":\"湘潭市\",\"s\":[{\"n\":\"雨湖区\"},{\"n\":\"岳塘区\"},{\"n\":\"湘潭县\"},{\"n\":\"湘乡市\"},{\"n\":\"韶山市\"}]},{\"n\":\"衡阳市\",\"s\":[{\"n\":\"珠晖区\"},{\"n\":\"雁峰区\"},{\"n\":\"石鼓区\"},{\"n\":\"蒸湘区\"},{\"n\":\"南岳区\"},{\"n\":\"衡阳县\"},{\"n\":\"衡南县\"},{\"n\":\"衡山县\"},{\"n\":\"衡东县\"},{\"n\":\"祁东县\"},{\"n\":\"耒阳市\"},{\"n\":\"常宁市\"}]},{\"n\":\"邵阳市\",\"s\":[{\"n\":\"双清区\"},{\"n\":\"大祥区\"},{\"n\":\"北塔区\"},{\"n\":\"邵东县\"},{\"n\":\"新邵县\"},{\"n\":\"邵阳县\"},{\"n\":\"隆回县\"},{\"n\":\"洞口县\"},{\"n\":\"绥宁县\"},{\"n\":\"新宁县\"},{\"n\":\"城步苗族自治县\"},{\"n\":\"武冈市\"}]},{\"n\":\"岳阳市\",\"s\":[{\"n\":\"岳阳楼区\"},{\"n\":\"云溪区\"},{\"n\":\"君山区\"},{\"n\":\"岳阳县\"},{\"n\":\"华容县\"},{\"n\":\"湘阴县\"},{\"n\":\"平江县\"},{\"n\":\"汨罗市\"},{\"n\":\"临湘市\"}]},{\"n\":\"常德市\",\"s\":[{\"n\":\"武陵区\"},{\"n\":\"鼎城区\"},{\"n\":\"安乡县\"},{\"n\":\"汉寿县\"},{\"n\":\"澧县\"},{\"n\":\"临澧县\"},{\"n\":\"桃源县\"},{\"n\":\"石门县\"},{\"n\":\"津市市\"}]},{\"n\":\"张家界市\",\"s\":[{\"n\":\"永定区\"},{\"n\":\"武陵源区\"},{\"n\":\"慈利县\"},{\"n\":\"桑植县\"}]},{\"n\":\"益阳市\",\"s\":[{\"n\":\"资阳区\"},{\"n\":\"赫山区\"},{\"n\":\"南县\"},{\"n\":\"桃江县\"},{\"n\":\"安化县\"},{\"n\":\"沅江市\"}]},{\"n\":\"郴州市\",\"s\":[{\"n\":\"北湖区\"},{\"n\":\"苏仙区\"},{\"n\":\"桂阳县\"},{\"n\":\"宜章县\"},{\"n\":\"永兴县\"},{\"n\":\"嘉禾县\"},{\"n\":\"临武县\"},{\"n\":\"汝城县\"},{\"n\":\"桂东县\"},{\"n\":\"安仁县\"},{\"n\":\"资兴市\"}]},{\"n\":\"永州市\",\"s\":[{\"n\":\"零陵区\"},{\"n\":\"冷水滩区\"},{\"n\":\"祁阳县\"},{\"n\":\"东安县\"},{\"n\":\"双牌县\"},{\"n\":\"道县\"},{\"n\":\"江永县\"},{\"n\":\"宁远县\"},{\"n\":\"蓝山县\"},{\"n\":\"新田县\"},{\"n\":\"江华瑶族自治县\"}]},{\"n\":\"怀化市\",\"s\":[{\"n\":\"鹤城区\"},{\"n\":\"中方县\"},{\"n\":\"沅陵县\"},{\"n\":\"辰溪县\"},{\"n\":\"溆浦县\"},{\"n\":\"会同县\"},{\"n\":\"麻阳苗族自治县\"},{\"n\":\"新晃侗族自治县\"},{\"n\":\"芷江侗族自治县\"},{\"n\":\"靖州苗族侗族自治县\"},{\"n\":\"通道侗族自治县\"},{\"n\":\"洪江市\"}]},{\"n\":\"娄底市\",\"s\":[{\"n\":\"娄星区\"},{\"n\":\"双峰县\"},{\"n\":\"新化县\"},{\"n\":\"冷水江市\"},{\"n\":\"涟源市\"}]},{\"n\":\"湘西土家族苗族自治州\",\"s\":[{\"n\":\"吉首市\"},{\"n\":\"泸溪县\"},{\"n\":\"凤凰县\"},{\"n\":\"花垣县\"},{\"n\":\"保靖县\"},{\"n\":\"古丈县\"},{\"n\":\"永顺县\"},{\"n\":\"龙山县\"}]}],\"n\":\"湖南省\"},{\"s\":[{\"n\":\"广州市\",\"s\":[{\"n\":\"荔湾区\"},{\"n\":\"越秀区\"},{\"n\":\"海珠区\"},{\"n\":\"天河区\"},{\"n\":\"白云区\"},{\"n\":\"黄埔区\"},{\"n\":\"番禺区\"},{\"n\":\"花都区\"},{\"n\":\"南沙区\"},{\"n\":\"萝岗区\"},{\"n\":\"增城市\"},{\"n\":\"从化市\"}]},{\"n\":\"韶关市\",\"s\":[{\"n\":\"武江区\"},{\"n\":\"浈江区\"},{\"n\":\"曲江区\"},{\"n\":\"始兴县\"},{\"n\":\"仁化县\"},{\"n\":\"翁源县\"},{\"n\":\"乳源瑶族自治县\"},{\"n\":\"新丰县\"},{\"n\":\"乐昌市\"},{\"n\":\"南雄市\"}]},{\"n\":\"深圳市\",\"s\":[{\"n\":\"罗湖区\"},{\"n\":\"福田区\"},{\"n\":\"南山区\"},{\"n\":\"宝安区\"},{\"n\":\"龙岗区\"},{\"n\":\"盐田区\"}]},{\"n\":\"珠海市\",\"s\":[{\"n\":\"香洲区\"},{\"n\":\"斗门区\"},{\"n\":\"金湾区\"}]},{\"n\":\"汕头市\",\"s\":[{\"n\":\"龙湖区\"},{\"n\":\"金平区\"},{\"n\":\"濠江区\"},{\"n\":\"潮阳区\"},{\"n\":\"潮南区\"},{\"n\":\"澄海区\"},{\"n\":\"南澳县\"}]},{\"n\":\"佛山市\",\"s\":[{\"n\":\"禅城区\"},{\"n\":\"南海区\"},{\"n\":\"顺德区\"},{\"n\":\"三水区\"},{\"n\":\"高明区\"}]},{\"n\":\"江门市\",\"s\":[{\"n\":\"蓬江区\"},{\"n\":\"江海区\"},{\"n\":\"新会区\"},{\"n\":\"台山市\"},{\"n\":\"开平市\"},{\"n\":\"鹤山市\"},{\"n\":\"恩平市\"}]},{\"n\":\"湛江市\",\"s\":[{\"n\":\"赤坎区\"},{\"n\":\"霞山区\"},{\"n\":\"坡头区\"},{\"n\":\"麻章区\"},{\"n\":\"遂溪县\"},{\"n\":\"徐闻县\"},{\"n\":\"廉江市\"},{\"n\":\"雷州市\"},{\"n\":\"吴川市\"}]},{\"n\":\"茂名市\",\"s\":[{\"n\":\"茂南区\"},{\"n\":\"茂港区\"},{\"n\":\"电白县\"},{\"n\":\"高州市\"},{\"n\":\"化州市\"},{\"n\":\"信宜市\"}]},{\"n\":\"肇庆市\",\"s\":[{\"n\":\"端州区\"},{\"n\":\"鼎湖区\"},{\"n\":\"广宁县\"},{\"n\":\"怀集县\"},{\"n\":\"封开县\"},{\"n\":\"德庆县\"},{\"n\":\"高要市\"},{\"n\":\"四会市\"}]},{\"n\":\"惠州市\",\"s\":[{\"n\":\"惠城区\"},{\"n\":\"惠阳区\"},{\"n\":\"博罗县\"},{\"n\":\"惠东县\"},{\"n\":\"龙门县\"}]},{\"n\":\"梅州市\",\"s\":[{\"n\":\"梅江区\"},{\"n\":\"梅县\"},{\"n\":\"大埔县\"},{\"n\":\"丰顺县\"},{\"n\":\"五华县\"},{\"n\":\"平远县\"},{\"n\":\"蕉岭县\"},{\"n\":\"兴宁市\"}]},{\"n\":\"汕尾市\",\"s\":[{\"n\":\"城区\"},{\"n\":\"海丰县\"},{\"n\":\"陆河县\"},{\"n\":\"陆丰市\"}]},{\"n\":\"河源市\",\"s\":[{\"n\":\"源城区\"},{\"n\":\"紫金县\"},{\"n\":\"龙川县\"},{\"n\":\"连平县\"},{\"n\":\"和平县\"},{\"n\":\"东源县\"}]},{\"n\":\"阳江市\",\"s\":[{\"n\":\"江城区\"},{\"n\":\"阳西县\"},{\"n\":\"阳东县\"},{\"n\":\"阳春市\"}]},{\"n\":\"清远市\",\"s\":[{\"n\":\"清城区\"},{\"n\":\"清新区\"},{\"n\":\"佛冈县\"},{\"n\":\"阳山县\"},{\"n\":\"连山壮族瑶族自治县\"},{\"n\":\"连南瑶族自治县\"},{\"n\":\"英德市\"},{\"n\":\"连州市\"}]},{\"n\":\"东莞市\"},{\"n\":\"中山市\"},{\"n\":\"潮州市\",\"s\":[{\"n\":\"湘桥区\"},{\"n\":\"潮安区\"},{\"n\":\"饶平县\"}]},{\"n\":\"揭阳市\",\"s\":[{\"n\":\"榕城区\"},{\"n\":\"揭东区\"},{\"n\":\"揭西县\"},{\"n\":\"惠来县\"},{\"n\":\"普宁市\"}]},{\"n\":\"云浮市\",\"s\":[{\"n\":\"云城区\"},{\"n\":\"新兴县\"},{\"n\":\"郁南县\"},{\"n\":\"云安县\"},{\"n\":\"罗定市\"}]}],\"n\":\"广东省\"}]";
//        String data="[{ \"s\": [{ \"s\": [{ \"code\": \"65009001001\", \"n\": \"平西梁村\" }, { \"code\": \"65009001002\", \"n\": \"小东沟村\" }, { \"code\": \"65009001003\", \"n\": \"方家庄村\" }, { \"code\": \"65009001004\", \"n\": \"溪水社区\" }, { \"code\": \"65009001005\", \"n\": \"南滩路社区\" }, { \"code\": \"65009001006\", \"n\": \"闸滩村\" }, { \"code\": \"65009001007\", \"n\": \"南河路社区\" }, { \"code\": \"65009001008\", \"n\": \"东梁村\" }, { \"code\": \"65009001009\", \"n\": \"大庙村\" }, { \"code\": \"65009001010\", \"n\": \"水西沟镇东湾村\" }, { \"code\": \"65009001011\", \"n\": \"庙尔沟村\" }, { \"code\": \"65009001012\", \"n\": \"水西沟村\" }], \"code\": \"65009001\", \"n\": \"水西沟镇\" }, { \"s\": [{ \"code\": \"65009002001\", \"n\": \"雪莲谷社区\" }, { \"code\": \"65009002002\", \"n\": \"赵家庄子村\" }], \"code\": \"65009002\", \"n\": \"萨尔达坂乡\" }, { \"s\": [{ \"code\": \"65009003001\", \"n\": \"团结村\" }, { \"code\": \"65009003002\", \"n\": \"前进村\" }, { \"code\": \"65009003003\", \"n\": \"菊花台社区\" }, { \"code\": \"65009003004\", \"n\": \"东风村\" }, { \"code\": \"65009003005\", \"n\": \"小渠子村\" }, { \"code\": \"65009003006\", \"n\": \"白杨沟村\" }, { \"code\": \"65009003007\", \"n\": \"天山村\" }, { \"code\": \"65009003008\", \"n\": \"高潮村\" }, { \"code\": \"65009003009\", \"n\": \"土圈村\" }], \"code\": \"65009003\", \"n\": \"甘沟乡\" }, { \"s\": [{ \"code\": \"65009004001\", \"n\": \"亚心社区\" }, { \"code\": \"65009004002\", \"n\": \"公盛村\" }, { \"code\": \"65009004003\", \"n\": \"下寺村\" }, { \"code\": \"65009004004\", \"n\": \"永丰村\" }, { \"code\": \"65009004005\", \"n\": \"永盛村\" }, { \"code\": \"65009004006\", \"n\": \"上寺村\" }, { \"code\": \"65009004007\", \"n\": \"永新村\" }], \"code\": \"65009004\", \"n\": \"永丰镇\" }, { \"s\": [{ \"code\": \"65009005001\", \"n\": \"东白杨沟村\" }, { \"code\": \"65009005002\", \"n\": \"灯草沟村\" }, { \"code\": \"65009005003\", \"n\": \"板房沟村\" }, { \"code\": \"65009005004\", \"n\": \"七工村\" }, { \"code\": \"65009005005\", \"n\": \"八家户村\" }, { \"code\": \"65009005006\", \"n\": \"中梁村\" }, { \"code\": \"65009005007\", \"n\": \"合盛村\" }, { \"code\": \"65009005008\", \"n\": \"板房沟镇东湾村\" }, { \"code\": \"65009005009\", \"n\": \"天峡社区\" }, { \"code\": \"65009005010\", \"n\": \"琴苑社区\" }], \"code\": \"65009005\", \"n\": \"板房沟镇\" }, { \"s\": [{ \"code\": \"65009006001\", \"n\": \"苜蓿台社区\" }, { \"code\": \"65009006002\", \"n\": \"乌什城村\" }, { \"code\": \"65009006003\", \"n\": \"羊圈沟村\" }, { \"code\": \"65009006004\", \"n\": \"白建沟村\" }], \"code\": \"65009006\", \"n\": \"托里乡\" }, { \"s\": [{ \"code\": \"65009007001\", \"n\": \"清水泉社区\" }, { \"code\": \"65009007002\", \"n\": \"乌拉泊村\" }], \"code\": \"65009007\", \"n\": \"清水泉片区管委会\" }, { \"s\": [{ \"code\": \"65009008001\", \"n\": \"硫磺沟社区\" }, { \"code\": \"65009008002\", \"n\": \"谢家沟社区\" }], \"code\": \"65009008\", \"n\": \"谢家沟片区管委会\" }], \"code\": \"65800\", \"n\": \"乌鲁木齐县\" }]";
        return data;
    }


    @GetMapping("/findByTel")
    @ResponseBody
    public AjaxResult findByTel(String tel)
    {
        ApplicationInfo applicationInfo=applicationInfoService.selectApplicationInfoByTel(tel);
        if(applicationInfo!=null){
            String b_spzt = dictDataMapper.selectDictLabel("b_spzt", applicationInfo.getSpzt());
            return new AjaxResult(AjaxResult.Type.SUCCESS, b_spzt,applicationInfo.getShyj());
        }


        return new AjaxResult(AjaxResult.Type.ERROR, "未查到数据！");

    }
    /**
     * 根据用户身份证号检查用户是否有“护送”角色权限
     * @param idCardNo
     * @return
     */
    @PostMapping("checkescort")
    @ResponseBody
    public AjaxResult checkEscortRoleByIdCard(String idCardNo){
        boolean haveRole=apiApplicationInfoService.checkRoleByIdCard("escort",idCardNo);
        if(haveRole){
            return success("具有“护送人员”权限");
        }else{
            return error("不具有“护送人员”权限");
        }
    }

    /**
     * 申请人到达指定位置时记录一下当前的时间节点
     * @param escortActionDto 这么几个属性是必须的：<br>
     *                        1.glsqdxId<br>
     *                        2.hsrySfzh<br>
     *                        3.qrxx<br>
     *                        4.cwlx:这个是条件性选填，如果第三个参数qrxx=false则当前参数为必须，否则非必需<br>
     *                        5.dz:目前支持两个动作"lkzs":离开酒店;"ddzt":到达车站或机场
     * @return
     */
    @PostMapping("changelocation")
    @ResponseBody
    public AjaxResult changeLocation(EscortActionDto escortActionDto){
        String lkzs="lkzs";
        String ddzt="ddzt";
        String dz=escortActionDto.getDz();
        if(StringUtils.isNotEmpty(dz)&&(lkzs.equals(dz)||ddzt.equals(dz))){
            return apiApplicationInfoService.changeLocation(escortActionDto);
        }else{
            logger.error("获取到了错误的动作标识：{}",dz);
            return error(String.format("动作标志代码填写错误：“%s”表示离开住所，“%s”表示到达机场或火车站",lkzs,ddzt));
        }
    }

    /**
     * 根据申请对象id查询申请对象数据
     * @param applicationInfoId
     * @param qqrSfzh 请求人人员身份证号
     * @return
     */
    @PostMapping("applicationInfo/{applicationInfoId}")
    @ResponseBody
    public AjaxResult selectApInfoById(@PathVariable("applicationInfoId") String applicationInfoId,String qqrSfzh){
        if(StringUtils.isEmpty(qqrSfzh)||!apiApplicationInfoService.checkRoleByIdCard("escort",qqrSfzh)){
            logger.info("身份证号为“{}”的人员在尝试查询id=“{}”的离乌申请对象数据，因为没有权限，已被拒绝",qqrSfzh,applicationInfoId);
            return error("查询失败，您没有权限查询该数据");
        }
        ApplicationInfo applicationInfo=applicationInfoService.selectApplicationInfoById(applicationInfoId);

        if(applicationInfo!=null){
            logger.info("身份证号为“{}”的人员成功查询了id=“{}”的离乌申请对象数据",qqrSfzh,applicationInfoId);
        }else{
            logger.info("身份证号为“{}”的人员在尝试查询id=“{}”的离乌申请对象数据，已成功查询，但没有找到对应数据",qqrSfzh,applicationInfoId);
        }
        return AjaxResult.success("查询成功",applicationInfo);
    }



    @RequestMapping(value = "upload", method=RequestMethod.POST)
    @ResponseBody
    public AjaxResult upload(String aid,String filepath, @RequestParam MultipartFile[] files) {
        if (StringUtils.isNotBlank(aid)){

                StringBuilder sBuilder=new StringBuilder();
                for (int i = 0; i < files.length; i++) {
                    MultipartFile file=files[i];
                    String fileName = file.getOriginalFilename();
                    String extension = FilenameUtils.getExtension(fileName);

                    if (null!=extension ) {
                        String picname=UUID.randomUUID().toString().replaceAll("-", "");
                        String uploadPath=filepath+"/upload/";
                        String filePath = uploadPath +picname+ file.getOriginalFilename();
                        File saveDir = new File(filePath);
                        if (!saveDir.getParentFile().exists())
                            saveDir.getParentFile().mkdirs();
                        try {
                            file.transferTo(saveDir);
                            sBuilder.append(filePath).append(",");
                        }catch (IOException e) {
                            e.printStackTrace();
                            return error(e.getMessage());
                        }
                    }
                    System.out.println(sBuilder.toString());
                }

                return AjaxResult.success("成功",sBuilder.toString());

        }else{
            return error("fail");
        }
    }
}
